home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / bbsutil / bsrc_250.zip / YOOHOO.C < prev    next >
C/C++ Source or Header  |  1991-09-15  |  19KB  |  596 lines

  1. /*--------------------------------------------------------------------------*/
  2. /*                                                                          */
  3. /*                                                                          */
  4. /*      ------------         Bit-Bucket Software, Co.                       */
  5. /*      \ 10001101 /         Writers and Distributors of                    */
  6. /*       \ 011110 /          Freely Available<tm> Software.                 */
  7. /*        \ 1011 /                                                          */
  8. /*         ------                                                           */
  9. /*                                                                          */
  10. /*  (C) Copyright 1987-91, Bit Bucket Software Co., a Delaware Corporation. */
  11. /*                                                                          */
  12. /*                                                                          */
  13. /*               This module was written by Vince Perriello                 */
  14. /*                                                                          */
  15. /*                                                                          */
  16. /*                     BinkleyTerm "YooHoo" Processor                       */
  17. /*                                                                          */
  18. /*                                                                          */
  19. /*    For complete  details  of the licensing restrictions, please refer    */
  20. /*    to the License  agreement,  which  is published in its entirety in    */
  21. /*    the MAKEFILE and BT.C, and also contained in the file LICENSE.250.    */
  22. /*                                                                          */
  23. /*    USE  OF THIS FILE IS SUBJECT TO THE  RESTRICTIONS CONTAINED IN THE    */
  24. /*    BINKLEYTERM  LICENSING  AGREEMENT.  IF YOU DO NOT FIND THE TEXT OF    */
  25. /*    THIS  AGREEMENT IN ANY OF THE  AFOREMENTIONED FILES,  OR IF YOU DO    */
  26. /*    NOT HAVE THESE FILES,  YOU  SHOULD  IMMEDIATELY CONTACT BIT BUCKET    */
  27. /*    SOFTWARE CO.  AT ONE OF THE  ADDRESSES  LISTED BELOW.  IN NO EVENT    */
  28. /*    SHOULD YOU  PROCEED TO USE THIS FILE  WITHOUT HAVING  ACCEPTED THE    */
  29. /*    TERMS  OF  THE  BINKLEYTERM  LICENSING  AGREEMENT,  OR  SUCH OTHER    */
  30. /*    AGREEMENT AS YOU ARE ABLE TO REACH WITH BIT BUCKET SOFTWARE, CO.      */
  31. /*                                                                          */
  32. /*                                                                          */
  33. /* You can contact Bit Bucket Software Co. at any one of the following      */
  34. /* addresses:                                                               */
  35. /*                                                                          */
  36. /* Bit Bucket Software Co.        FidoNet  1:104/501, 1:343/491             */
  37. /* P.O. Box 460398                AlterNet 7:491/0                          */
  38. /* Aurora, CO 80046               BBS-Net  86:2030/1                        */
  39. /*                                Internet f491.n343.z1.fidonet.org         */
  40. /*                                                                          */
  41. /* Please feel free to contact us at any time to share your comments about  */
  42. /* our software and/or licensing policies.                                  */
  43. /*                                                                          */
  44. /*                                                                          */
  45. /*--------------------------------------------------------------------------*/
  46.  
  47. /* Include this file before any other includes or defines! */
  48.  
  49. #include "includes.h"
  50.  
  51. int Send_Hello_Packet (int);
  52. int Recv_Hello_Packet (int);
  53.  
  54. /*--------------------------------------------------------------------------*/
  55. /* YOOHOO SENDER    (used when I am the CALLING system)                     */
  56. /*--------------------------------------------------------------------------*/
  57. int YooHoo_Sender (void)
  58. {
  59.    char *sptr;
  60.  
  61.    if (un_attended && fullscreen)
  62.       {
  63.       sb_move (file_hWnd, 2, 2);
  64.       FlLnModeSet( FILE_LN_2, 0 );
  65.       sb_puts( GetDlgItem( file_hWnd, FILE_LN_2 ), "YooHoo" );
  66.       sb_show ();
  67.       }
  68.    else
  69.       {
  70.       set_xy ("YooHoo ");
  71.       }
  72.  
  73.    /*--------------------------------------------------------------------*/
  74.    /* Clean up any mess that may be around                               */
  75.    /*--------------------------------------------------------------------*/
  76.    CLEAR_OUTBOUND ();
  77.    CLEAR_INBOUND ();
  78.    XON_DISABLE ();
  79.  
  80.    if (!Send_Hello_Packet (1))
  81.       sptr = MSG_TXT(M_HE_HUNG_UP);
  82.  
  83.    else
  84.       {
  85.       if (TIMED_READ (30) == YOOHOO)
  86.          return Recv_Hello_Packet (1);
  87.  
  88.       status_line ("!No YOOHOO/2U2");
  89.       sptr = IDUNNO_msg;
  90.       }
  91.  
  92.    status_line (sptr);
  93.    return (0);
  94. }
  95.  
  96. /*--------------------------------------------------------------------------*/
  97. /* YOOHOO RECEIVER  (Used when I am the CALLED system)                      */
  98. /*--------------------------------------------------------------------------*/
  99.  
  100. int YooHoo_Receiver (void)
  101. {
  102.    int i;
  103.    int c;
  104.  
  105.    if (un_attended && fullscreen)
  106.       {
  107.       sb_move (file_hWnd, 2, 2);
  108.       FlLnModeSet( FILE_LN_2, 0 );
  109.       sb_puts( GetDlgItem( file_hWnd, FILE_LN_2 ), "YooHoo" );
  110.       sb_show ();
  111.       }
  112.    else
  113.       {
  114.       set_xy ("YooHoo ");
  115.       }
  116.  
  117.    /*--------------------------------------------------------------------*/
  118.    /* Clean up any mess that may be around                               */
  119.    /*--------------------------------------------------------------------*/
  120.    CLEAR_OUTBOUND ();
  121.    CLEAR_INBOUND ();
  122.    XON_DISABLE ();
  123.  
  124.    if (Recv_Hello_Packet(0) == 0)
  125.       return (0);
  126.  
  127.    for (i = 0; (CARRIER) && (i < 10); i++)
  128.       {
  129.       if ((c = TIMED_READ (10)) == ENQ)
  130.          {
  131.          if ((i = Send_Hello_Packet (0)) == 0)
  132.             b_init ();
  133.          return (i);
  134.          }
  135.  
  136.       if (c > 0)
  137.          {
  138.          (void) printf ("[%x] ", c);
  139.  
  140.          /* Delay one second, then try again */
  141.          big_pause (1);
  142.  
  143.          CLEAR_INBOUND ();
  144.          }
  145.  
  146.       SENDBYTE (YOOHOO);
  147.       }
  148.  
  149.    status_line (MSG_TXT(M_FUBAR_MSG));
  150.    b_init ();
  151.    return (0);
  152.  
  153. }                                                /* YooHoo Receiver */
  154.  
  155. /*--------------------------------------------------------------------------*/
  156. /* SEND HELLO PACKET                                                        */
  157. /*--------------------------------------------------------------------------*/
  158. int Send_Hello_Packet (int Sender)
  159. {
  160.    int i;
  161.    struct _Hello Hello;
  162.    char *sptr;
  163.    long response_timer;
  164.    word crc;
  165.    word num_errs = 0;
  166.    word can_do_domain = 0;
  167.    char junkbuff[128];
  168.  
  169.    /*--------------------------------------------------------------------*/
  170.    /* Setup HELLO structure                                              */
  171.    /*--------------------------------------------------------------------*/
  172.    (void) memset ((char *) &Hello, 0, sizeof (struct _Hello));
  173.  
  174.    Hello.signal = 'o';
  175.    Hello.hello_version = 1;
  176.  
  177.    Hello.product = PRDCT_CODE;
  178.    Hello.product_maj = BINK_MAJVERSION;
  179.    Hello.product_min = BINK_MINVERSION;
  180.  
  181.    (void) strncpy (Hello.sysop, sysop, 19);
  182.    Hello.sysop[19] = '\0';
  183.  
  184.    Hello.my_zone = alias[assumed].Zone;
  185.    if ((pvtnet >= 0) && (Sender) &&
  186.        ((called_addr.Zone == boss_addr.Zone) || (called_addr.Zone == 0) || (boss_addr.Zone == 0)) &&
  187.        (called_addr.Net == boss_addr.Net) && (called_addr.Node == boss_addr.Node) &&
  188.        ((called_addr.Domain == boss_addr.Domain) || (boss_addr.Domain == NULL) || (called_addr.Domain == NULL)))
  189.       {
  190.       Hello.my_net = boss_addr.Net;
  191.       Hello.my_node = boss_addr.Node;
  192.       Hello.my_point = alias[assumed].Node;
  193.       }
  194.    else
  195.       {
  196.       Hello.my_net = alias[assumed].Net;
  197.       Hello.my_node = alias[assumed].Node;
  198.       Hello.my_point = alias[assumed].Point;
  199.       }
  200. /*
  201.  * If we are the calling system, turn on all our capabilities.
  202.  * If we are the called system, choose from the set that the
  203.  * c